package com.dycx.api.controller.manage.message;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dycx.common.RestResponse;
import com.dycx.message.dto.MessageTaskDTO;
import com.dycx.message.service.MessageTaskService;
import com.dycx.message.vo.MessageTaskVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 模版任务表(MessageTask)表控制层
 *
 * @author wuzongbin
 * @since 2023-11-14 09:23:58
 */
@RestController
@RequestMapping(value = "/manage/message/messageTask")
public class MessageTaskController {
    /**
     * 服务对象
     */
    @Resource
    private MessageTaskService messageTaskService;

    /**
     * 分页
     **/
    @PostMapping("/getPage")
    public RestResponse<Page<MessageTaskVO>> getPage(@RequestBody MessageTaskDTO dto) {
        return RestResponse.success(messageTaskService.getPage(dto));
    }

    /**
     * 查询详细
     **/
    @GetMapping("/load")
    public RestResponse<MessageTaskVO> load(Integer id) {
        return RestResponse.success(messageTaskService.load(id));
    }

    /**
     * 添加
     **/
    @PostMapping("/create")
    public RestResponse<Boolean> create(@RequestBody @Valid MessageTaskDTO dto) {
        return messageTaskService.create(dto) ? RestResponse.success() : RestResponse.fail();
    }

    /**
     * 修改
     **/
    @PostMapping("/edit")
    public RestResponse<Boolean> edit(@RequestBody @Valid MessageTaskDTO dto) {
        return messageTaskService.edit(dto) ? RestResponse.success() : RestResponse.fail();
    }


    /**
     * 刪除
     **/
    @GetMapping("/delete")
    public RestResponse<Boolean> delete(Integer id) {
        return messageTaskService.delete(id) ? RestResponse.success() : RestResponse.fail();
    }
}

